﻿@model TidyBlog.MVC.WWW.Models.ListWithPaginator<TidyBlog.Entity.Comment>

@{
	ViewBag.Title = "评论管理";
	Layout = "~/Views/Shared/_ManageLayout.cshtml";
}

@if (Model.Result != null)
{
<form action="@Url.Action("Batch")" method="post">
	<table>
		<thead>
			<tr>
				<th style="width: 5%;"><input id="selectAll" type="checkbox" /></th>
				<th style="width: 12%;">作者</th>
				<th style="width: 28%">作者信息</th>
				<th style="width: 12%;">发表时间</th>
				<th style="width: 7%;">状态</th>
				<th style="width: 36%;">内容</th>
			</tr>
		</thead>
	@if (Model.Result.PageCount > 1)
	{
		<tfoot>
			<tr><td colspan="6">@{ Html.RenderPartial("_paginator", Model.ResultPaginator); }</td></tr>
		</tfoot>
	}
		<tbody>
	@if (Model.Result.Data == null || Model.Result.Data.Count == 0)
	{
			<tr><td colspan="6" style="text-align: center;">暂无符合条件的数据</td></tr>
	}
	else
	{
		foreach (var comment in Model.Result.Data)
		{
			var article = TidyBlog.BLL.ArticleBLL.Read(comment.ArticleId);
			<tr>
				<td style="text-align: center;"><input name="commentIds" type="checkbox" value="@comment.CommentId" /></td>
				<td>@comment.AuthorName</td>
				<td style="line-height: 23px;">IP：@comment.IP<br />Email：@comment.Email<br />主页：@comment.HomePage</td>
				<td style="text-align: center; line-height: 23px;">@Html.Raw(comment.PostTime.AddHours(ViewBag.Setup.TimeZone).ToString("HH:mm:ss<br />yyyy-MM-dd"))</td>
				<td style="text-align: center;">@(0 == comment.Visibility ? "未审" : "已审")</td>
				<td style="line-height: 23px;">
					<a href="@Url.Action("Detail", "Article", new { id = comment.ArticleId })" target="_blank">《@article.Title》</a><br />
					@Html.Raw(Server.HtmlEncode(comment.Content).Replace("\r\n", "<br />"))
				</td>
			</tr>
		}
			<tr>
				<td colspan="6" class="buttons" style="text-align: left; padding-left: 1em;">
					<select name="action">
						<option value="review">批量审核</option>
						<option value="delete">批量删除</option>
					</select>
					<input type="submit" value="提 交" />
				</td>
			</tr>
	}
		</tbody>
	</table>
</form>
}

@section Script{
<script>
require('dom/1.0.x/', function($) {
	$('form').on('submit', function(e) {
		if ( !window.confirm('确认要进行此操作吗？') ) {
			e.preventDefault();
		}
	});
	$('#selectAll').click(function() {
		$('input').attr('checked', this.checked);
	});
});
</script>
}